//


//

#pragma once

#include <iostream>
#include <iomanip>



#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE

#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>



class SpdlogInitializer {
public:
    SpdlogInitializer() {
        static std::atomic<int> call_count{0};
        int count = ++call_count;
        std::cerr << "DEBUG: SpdlogInitializer constructor called " << count << " times" << std::endl;
        
        try {
            
            
            auto console_logger = spdlog::stdout_color_mt("console");
            spdlog::set_default_logger(console_logger);
            
            
            spdlog::set_pattern("[%H:%M:%S.%e] [%^%L%$] [%!:%#] %v");;
            spdlog::set_level(spdlog::level::info);  
            
            
            spdlog::info("SpdlogInitializer: Logger initialized successfully");
        } catch (const std::exception& e) {
            std::cerr << "Failed to initialize spdlog: " << e.what() << std::endl;
        }
    }
    
    ~SpdlogInitializer() = default;
};



inline static SpdlogInitializer spdlog_init;

#define JC_INFO(...) SPDLOG_INFO(__VA_ARGS__)
#define JC_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__)
#define JC_WARN(...) SPDLOG_WARN(__VA_ARGS__)
#define JC_ERROR(...) SPDLOG_ERROR(__VA_ARGS__)

#define JC_CRITICAL(...) SPDLOG_CRITICAL(__VA_ARGS__)
#define JC_TRACE(...) SPDLOG_TRACE(__VA_ARGS__)
#define JC_FATAL(...) SPDLOG_FATAL(__VA_ARGS__)
